object ScoreFunctionErrorDemo {
  def main(args: Array[String]): Unit = {
    def calculateAverage(scores: List[Int]): Double = {
      if (scores.isEmpty) 0.0
      else scores.sum.toDouble / scores.length
    }
    def countPass(scores: List[Int], passLine: Int): Int = {
      var count = 0
      for (s <- scores) {
        if (s >= passLine) count += 1
      }
      count
    }
    def sum(scores: List[Int]): Int = {
      if (scores.isEmpty) 0
      else scores.head + sum(scores.tail)
    }
    val scores = List(85, 92, 58, 76, 88)
    println("平均分：" + calculateAverage(scores))
    println("及格人数：" + countPass(scores, 60))
    println("总分：" + sum(scores))
  }
}